import { ActionCreatorWithPayload } from "redux"
import { RESET, SETACTIVE, SETTABBARVISIBILITY } from "../actionTypes/tabbar"

/**
 * reset tabbar store
 * @returns Action
 */
export const reset: ActionCreatorWithPayload<undefined> = () => {
  return {
    type: RESET,
    payload: undefined
  }
}
/**
 * set current activated tabbar
 * @param pagePath active tab `pagePath`
 * @returns Action
 */
export const setActive: ActionCreatorWithPayload<
  ITabbarStore["current"],
  ITabbarStore["current"]
> = (pagePath: ITabbarStore["current"]) => {
  return {
    type: SETACTIVE,
    payload: pagePath
  }
}

/**
 * show or hide tabbar
 * @param appear tabbar appear state
 * @returns Action
 */
export const changeVisibility: ActionCreatorWithPayload<boolean, boolean> = (appear: boolean) => {
  return {
    type: SETTABBARVISIBILITY,
    payload: appear
  }
}
